package com.alibaba.apm;



import brave.Tracing;

import zipkin2.Span;
import zipkin2.reporter.AsyncReporter;
import zipkin2.reporter.Reporter;
import zipkin2.reporter.okhttp3.OkHttpSender;


public class TracingConfig {


    /**
      从https://tracing-analysis.console.aliyun.com/获取zipkin的接入点（endpoint)
      例如 http://tracing-analysis-dc-hz.aliyuncs.com/adapt_aokcdqnxyz@123456ff_abcdef123@abcdef123/api/v2/spans
     */
    private static final String zipkinEndPoint = "hhttp://tracing-analysis-dc-hz.aliyuncs.com/adapt_aokcdqnxyz@123456ff_abcdef123@abcdef123/api/v2/spans";

    private static String localServiceName = "zipkinManualDemo";

    private static Tracing tracing = null;

    static {
        // 构建数据发送对象
        OkHttpSender sender = OkHttpSender.newBuilder().endpoint(zipkinEndPoint).build();

        // 构建数据上报对象
        Reporter<Span> reporter = AsyncReporter.builder(sender).build();

        tracing = Tracing.newBuilder().localServiceName(localServiceName).spanReporter(reporter).build();
    }


    public static Tracing getTracing() {
        return tracing;
    }

}
